This invention relates to the field of computer systems in general, and in particular to programming language compilers used on such computer systems. More specifically, the invention relates to a technique for optimizing the use of register windows in a windowed register architecture.
Computer systems are known which employ a windowed register architecture. In such an architecture, registers are grouped into a plurality of windows for each procedure, with each window having a fixed number of registers. As an example, in the SPARC-V9 architecture, each window includes a fixed number of registers (four groups of eight), grouped as in registers, local registers and out registers. The in and out registers are used primarily for passing parameters to and receiving results from subroutines, and for keeping track of the memory stack. A procedure may store temporary values in its out registers, and up to six parameters may be passed by placing them in the out registers. Typically, when a procedure is called and executes a SAVE instruction, the out registers allocated to the calling procedure become the in registers of the called procedure. When a register file overflows, one of the procedure out registers is used as a stack pointer and points to an area in a memory stack in which the system can store parameters or results until the overflow condition is alleviated. This stack pointer is also used to address most values located on the stack. Local registers are used for automatic variables, i.e., a local variable whose life time is no longer than that of its containing procedure, and for most temporary values. In addition to the windowed in, out and local registers, a set of global registers is also provided. The global registers are typically used for temporary values, global variables or global pointers--either user variables, or values maintained as part of a program's executive environment. In addition to the global registers, a set of floating-point registers is also provided for storing user variable and compiler temporaries and for other purposes. For a detailed discussion of additional software considerations of the SPARC-V9 architecture reference may be had to Appendix H of the SPARC Architecture Manual, Version 9, PTR Prentice Hall, Englewood Cliffs, N.J., the disclosure of which is hereby incorporated by reference.
Regardless of how many register windows are implemented by a given implementation, the number of register windows utilized by code written for a windowed register architecture may easily exceed the available number of windows. When this occurs, the contents of one or more register windows must be saved to the memory stack so that the execution of the procedure can proceed. As a consequence, it is frequently necessary to later restore the saved register window or windows.
The saving and restoring of register windows is traditionally handled within the operating system running on top of the compiler implementation. When it is necessary to save and restore register window(s), the operating system must be alerted to a register window overflow or underflow (i.e., the need to save or restore), and the handling of the register window condition and the subsequent save and restore operations require a substantial amount of run time, which expands the overall run time required for the program.